package com.huangpuweb.task.service.imp;


import com.huangpuweb.task.model.*;
import com.huangpuweb.task.service.PersonDataService;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

@Service
public class PersonDataServiceImpl extends BasePersonDataServiceImp implements PersonDataService {


    @Override
    public List<HpPersonHouseStatistics> getHpSyrkStreet() {
        String sql="select * from temp_hp_syrk_street";
        return getEntryList(sql,new HpPersonHouseStatisticsRowMapper(),new Object[]{});
    }

    @Override
    public List<HpPersonHouseStatistics> getHpSyrkPopuDistribution() {
        String sql="select * from temp_hp_syrk_popu_distribution";
        return getEntryList(sql,new HpPersonHouseStatisticsRowMapper(),new Object[]{});
    }

    @Override
    public List<HpPersonHouseStatistics> getHpSyrkHpPopu() {
        String sql="select * from temp_hp_syrk_hp_popu";
        return getEntryList(sql,new HpPersonHouseStatisticsRowMapper(),new Object[]{});
    }

    @Override
    public List<HpPersonHouseStatistics> getHpPersonHouseStatistics() {
        String sql="select * from temp_hp_syrk_house_statistics";
        return getEntryList(sql,new HpPersonHouseStatisticsRowMapper(),new Object[]{});
    }

    @Override
    public List<HpSyrkGender> getHpSyrkGender() {
        String sql="select * from hp_syrk_gender";
        return getEntryList(sql, new RowMapper<HpSyrkGender>() {
            @Override
            public HpSyrkGender mapRow(ResultSet resultSet, int i) throws SQLException {
                HpSyrkGender hs=new HpSyrkGender();
                hs.setAge_cnts(resultSet.getString("age_cnts"));
                hs.setId(resultSet.getInt("id"));
                hs.setLy(resultSet.getString("ly"));
                hs.setTimes(resultSet.getString("times"));
                hs.setSz(resultSet.getInt("sz"));
                return hs;
            }
        },new Object[]{});
    }

    @Override
    public List<HpSyrkAgeDistribute> getHpSyrkAgeDistribute() {
        String sql="select * from hp_syrk_age_distribute";
        return getEntryList(sql,new HpSyrkAgeDistributeRowMapper(),new Object[]{});
    }
}
